home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / MacPerl 5.1.3 / Mac_Perl_513_src / MacPerl5 / macscripts / Aete2Rez < prev    next >
Encoding:
Text File  |  1996-10-07  |  5.5 KB  |  282 lines  |  [TEXT/MPS ]

  1. Perl -Sx "{0}" {"Parameters"} ; Exit
  2. #!perl
  3.  
  4. while(<>) {
  5.     next if /^\s+$/;
  6.     next if /^\s*#/;
  7.     
  8.     if (/\@TITLE\s+\"([^"]*)\"/) {
  9.         print "resource \'aete\' (0, \"$1\") {\n";
  10.     } elsif (/\@VERSION\s+(\d+)\.(\d+)/) {
  11.         printf("\t0x%02d, 0x%02d, english, roman,\n", $1, $2);
  12.     } elsif (/\@SUITE\s+\"([^"]*)\"\s*,\s*\"([^"]*)\"\s*,\s*\'([^']*)\'/) {
  13.         if ($suites++) {
  14.             &finishsuite();
  15.             
  16.             print "\n";
  17.         } else {
  18.             print "\t{\n";
  19.         }
  20.         
  21.         ($events, $classes, $comparisons, $enumerations) = (0, 0, 0, 0);
  22.         
  23.         print "\t\t\"$1\", \"$2\", \'$3\', 1, 1,\n";
  24.     } elsif (/\@EVENT\s+\"([^"]*)\"\s*,\s*\"([^"]*)\"\s*,\s*\'([^']*)\'\s*,\s*\'([^']*)\'/) {
  25.         if ($events++) {
  26.             &finishevent();
  27.             print "\n";
  28.         } else {
  29.             print "\t\t{\n";
  30.         }
  31.  
  32.         print "\t\t\t\"$1\", \"$2\", \'$3\', \'$4\',\n";
  33.         
  34.         $params = 0;
  35.     } elsif (/\@REPLY\s+\'([^']*)\'\s*,\s*\"([^"]*)\"\s*,\s*(\w+)\s*,\s*(\w+)\s*,\s*(\w+)/) {
  36.         
  37.         print "\t\t\t\'$1\', \"$2\", ";
  38.         
  39.         if ($3 eq "REQ") {
  40.             print "replyRequired, ";
  41.         } elsif ($3 eq "OPT") {
  42.             print "replyOptional, ";
  43.         } else {
  44.             die;
  45.         }
  46.         
  47.         if ($4 eq "SINGLE") {
  48.             print "singleItem, ";
  49.         } elsif ($4 eq "LIST") {
  50.             print "listOfItems, ";
  51.         } else {
  52.             die;
  53.         }
  54.         
  55.         if ($5 eq "ENUM") {
  56.             print "enumerated, ";
  57.         } elsif ($5 eq "NOENUM") {
  58.             print "notEnumerated, ";
  59.         } else { 
  60.             die;
  61.         }
  62.         
  63.         print "reserved, " x 13, "\n";
  64.     } elsif (/\@DIRECT\s+\'([^']*)\'\s*,\s*\"([^"]*)\"\s*,\s*(\w+)\s*,\s*(\w+)\s*,\s*(\w+)s*,\s*(\w+)/) {
  65.         
  66.         print "\t\t\t\'$1\', \"$2\", ";
  67.         
  68.         if ($3 eq "REQ") {
  69.             print "directParamRequired, ";
  70.         } elsif ($3 eq "OPT") {
  71.             print "directParamOptional, ";
  72.         } else {
  73.             die;
  74.         }
  75.         
  76.         if ($4 eq "SINGLE") {
  77.             print "singleItem, ";
  78.         } elsif ($4 eq "LIST") {
  79.             print "listOfItems, ";
  80.         } else { 
  81.             die;
  82.         }
  83.         
  84.         if ($5 eq "ENUM") {
  85.             print "enumerated,\n";
  86.         } elsif ($5 eq "NOENUM") {
  87.             print "notEnumerated,\n";
  88.         } else {
  89.             die;
  90.         }
  91.         
  92.         if ($6 eq "CHANGE") {
  93.             print "\t\t\tchangesState, ";
  94.         } elsif ($6 eq "NOCHANGE") {
  95.             print "\t\t\tdoesntChangeState, ";
  96.         } else { 
  97.             die;
  98.         }
  99.         
  100.         print "reserved, " x 12, "\n";        
  101.     } elsif (/\@PARAM\s+\"([^"]*)\"\s*,\s*\'([^']*)\'\s*,\s*\'([^']*)\'\s*,\s*\"([^"]*)\"\s*,\s*(\w+)\s*,\s*(\w+)\s*,\s*(\w+)s*/) {
  102.         
  103.         print "\t\t\t{\n" unless $params++;
  104.         
  105.         print "\t\t\t\t\"$1\", \'$2\', \'$3\', \"$4\", ";
  106.         
  107.         if ($5 eq "REQ") {
  108.             print "required, ";
  109.         } elsif ($5 eq "OPT") {
  110.             print "optional, ";
  111.         } else {
  112.             die;
  113.         }
  114.         
  115.         if ($6 eq "SINGLE") {
  116.             print "singleItem, ";
  117.         } elsif ($6 eq "LIST") {
  118.             print "listOfItems, ";
  119.         } else { 
  120.             die;
  121.         }
  122.         
  123.         if ($7 eq "ENUM") {
  124.             print "enumerated, ";
  125.         } elsif ($7 eq "NOENUM") {
  126.             print "notEnumerated, ";
  127.         } else { 
  128.             die;
  129.         }
  130.         
  131.         print "reserved, " x 13, "\n";                
  132.     } elsif (/\@CLASS\s+\"([^"]*)\"\s*,\s*\'([^']*)\'\s*,\s*\"([^"]*)\"/) {
  133.         if ($classes++) {
  134.             &finishclass();
  135.         } else {        
  136.             if ($events) {
  137.                 &finishevent();
  138.                 
  139.                 print "\t\t},\n";
  140.             } else {
  141.                 print "\t\t{},\n";
  142.             }
  143.             
  144.             print "\t\t{\n";
  145.         }
  146.         
  147.         print "\t\t\t\"$1\", \'$2\', \"$3\",\n";
  148.         
  149.         ($properties,$elements) = (0, 0);
  150.     } elsif (/\@PROPERTY\s+\"([^"]*)\"\s*,\s*\'([^']*)\'\s*,\s*\'([^']*)\'\s*,\s*\"([^"]*)\"\s*,\s*(\w+)\s*,\s*(\w+)\s*,\s*(\w+)/) {
  151.         print "\t\t\t{\n" unless ($properties++);
  152.         
  153.         print "\t\t\t\t\"$1\", \'$2\', \'$3\', \"$4\", reserved, ";
  154.         
  155.         if ($5 eq "SINGLE") {
  156.             print "singleItem, ";
  157.         } elsif ($5 eq "LIST") {
  158.             print "listOfItems, ";
  159.         } else { 
  160.             die;
  161.         }
  162.         
  163.         if ($6 eq "ENUM") {
  164.             print "enumerated, ";
  165.         } elsif ($6 eq "NOENUM") {
  166.             print "notEnumerated, ";
  167.         } else { 
  168.             die;
  169.         }
  170.         
  171.         if ($7 eq "RDWR") {
  172.             print "readWrite, ";
  173.         } elsif ($7 eq "RDONLY") {
  174.             print "readOnly, ";
  175.         } else {
  176.             die;
  177.         }
  178.         
  179.         print "reserved, " x 12, "\n";        
  180.     } elsif (/\@ELEMENT\s+\'([^']*)\'\s*,\s*(.*)/) {
  181.         unless ($elements++) {
  182.             if ($properties++) {
  183.                 print "\t\t\t},\n";
  184.             } else {
  185.                 print "\t\t\t{},\n";
  186.             }
  187.                 
  188.             print "\t\t\t{\n";
  189.         }
  190.         
  191.         ($class, $forms) = ($1, $2);
  192.         $forms =~ s/ABSOLUTE/formAbsolutePosition/;
  193.         $forms =~ s/RELATIVE/formRelativePosition/;
  194.         $forms =~ s/RANGE/formRange/;
  195.         $forms =~ s/NAME/formName/;
  196.         $forms =~ s/ID/formUniqueID/;
  197.         
  198.         print "\t\t\t\t\'$class\', { $forms },\n";
  199.     } elsif (/\@ENUMERATION\s+\'([^']*)\'/) {
  200.         if ($enumerations++) {
  201.             &finishenumeration();
  202.         } else {
  203.             if ($comparisons) {
  204.                 &finishcomparison();
  205.                         
  206.                 print "\t\t},\n";
  207.             } elsif ($classes) {
  208.                 &finishclass();
  209.                 print "\t\t},\n\t\t{},\n";
  210.             } elsif ($events) {
  211.                 &finishevent();
  212.                         
  213.                 print "\t\t},\n\t\t{},\n\t\t{},\n";
  214.             } else {
  215.                 print "\t\t{},\n\t\t{},\n\t\t{},\n";
  216.             }
  217.                     
  218.             print "\t\t{\n";
  219.         }
  220.         
  221.         print "\t\t\t\'$1\',\n";
  222.         
  223.         $elements = 0;
  224.     } elsif (/\@ENUM\s+\"([^"]*)\"\s*,\s*\'([^']*)\'\s*,\s*\"([^"]*)\"/) {
  225.         if (!$elements++) {
  226.             print "\t\t\t{\n";
  227.         } 
  228.         
  229.         print "\t\t\t\t\"$1\", \'$2\', \"$3\",\n";
  230.     } else {
  231.         die "Syntax error";
  232.     }
  233. }
  234.  
  235. &finishsuite() if $suites;
  236.  
  237. print "\t}\n";
  238. print "};\n";
  239.  
  240. sub finishsuite {
  241.     if ($enumerations) {
  242.         &finishenumeration();
  243.         print "\t\t},\n";
  244.     } elsif ($comparisons) {
  245.         print "\t\t},\n\t\t{},\n";
  246.     } elsif ($classes) {
  247.         &finishclass();
  248.         print "\t\t},\n\t\t{},\n\t\t{},\n";
  249.     } elsif ($events) {
  250.         &finishevent();
  251.         print "\t\t},\n\t\t{},\n\t\t{},\n\t\t{},\n";
  252.     } else {
  253.         print "\t\t{},\n\t\t{},\n\t\t{},\n\t\t{},\n";
  254.     }
  255. }
  256.  
  257. sub finishevent {
  258.     if ($params) {
  259.         print "\t\t\t},\n";
  260.     } else {
  261.         print"\t\t\t{},\n";
  262.     }
  263. }
  264.  
  265. sub finishclass {
  266.     if ($elements) {
  267.         print "\t\t\t},\n";
  268.     } elsif ($properties) {
  269.         print "\t\t\t},\n\t\t\t{},\n";
  270.     } else {
  271.         print "\t\t\t{},\n\t\t\t{},\n";
  272.     }
  273. }
  274.  
  275. sub finishenumeration {
  276.     if ($elements) {
  277.         print "\t\t\t},\n";
  278.     } else {
  279.         print "\t\t\t{},\n";
  280.     }
  281. }
  282.